#include<bits/stdc++.h>
using namespace std;
int t,n,m,L,V,ans;
struct nodecar{
	int l,v,a,fst,lst;
	double eqV;
	bool ovr;
}car[100005];
int tec[100005];
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%d",&t);
	while(t--){
		scanf("%d%d%d%d",&n,&m,&L,&V);
		for(int i=1;i<=n;i++){
			scanf("%d%d%d",&car[i].l,&car[i].v,&car[i].a);
			if(car[i].a) car[i].eqV=(V*V-car[i].v*car[i].v)/(2*car[i].a);
		}
		for(int i=1;i<=m;i++){
			scanf("%d",&tec[i]);
		}
		for(int i=1;i<=n;i++){
			 if(car[i].v>V||car[i].eqV<=tec[m]) ans++;
		}
		int cnt=m-1;
		if(ans==0) m+=1;
		printf("%d %d\n",ans,cnt);
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
